<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>问卷调查管理系统</title>
  <link rel="stylesheet" href="layui/layui-v2.6.8/layui/css/layui.css">
  <link rel="stylesheet" href="css/bootstrap.min.css">
  <link rel="stylesheet" href="css/index.css">

</head>

<body style="background-image: url(jpg/110155iXIRs.jpg);">
  <div class="layui-layout layui-layout-admin" style="background:rgba(110, 108, 108, 0.5);">
    <div class="layui-header" style="margin-bottom: 3rem;">
      <div class="layui-logo layui-hide-xs ">导航</div>
      <!-- 头部区域（可配合layui 已有的水平导航） -->
      <ul class="layui-nav layui-layout-left">
        <!-- 移动端显示 -->
        <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
          <i class="layui-icon layui-icon-spread-left"></i>
        </li>

      </ul>
      <ul class="layui-nav layui-layout-right">
        <li class="layui-nav-item layui-hide layui-show-md-inline-block">
          <a href="javascript:;">
            {{username}}
          </a>
          <dl class="layui-nav-child">
            <dd><a href="information">你的个人资料</a></dd>
            <dd><a href="" onclick="logout()">退出</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
          <a href="javascript:;">
            <i class="layui-icon layui-icon-more-vertical"></i>
          </a>
        </li>
      </ul>
    </div>

    <div class="layui-side" style="margin-bottom: 3rem;background:rgba(110, 108, 108, 0.5);">
      <div style="background:rgba(110, 108, 108, 0.5);">
        <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
        <ul class="layui-nav layui-nav-tree" lay-filter="test"
          style="margin-bottom: 3rem;background:rgba(110, 108, 108, 0.5);">
          <li class="layui-nav-item layui-nav-itemed">
            <a class="" href="javascript:;">操作</a>
            <dl class="layui-nav-child">
              <button type="button" class="btn btn-secondary " data-toggle="modal" style="width: 14rem;"
                onclick="lookMeQ()">查看自身已填写的问卷</button>


              <div>
                <button type="button" class="btn btn-secondary " data-toggle="modal"
                  style="width: 14rem;margin-top: 50px;" onclick="newQuestionnaire()">新建问卷+</button>
              </div>
            </dl>
          </li>
        </ul>
      </div>
    </div>
  </div>

  <div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding: 15px; margin-top: 20px;background:rgba(110, 108, 108, 0.5);height: 800px;">
      <div style="margin-bottom: 5px;">

        <!-- 示例-970 -->
        <ins class="adsbygoogle" style="display:inline-block;width:970px;height:90px"
          data-ad-client="ca-pub-6111334333458862" data-ad-slot="3820120620"></ins>

      </div>



      <table class="layui-table" lay-data="{width: 1100, height:275, id:'Test'}" lay-filter="demo">

        <thead>
          <div>
            <tr>
              <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
              <th lay-data="{field:'id', width:110, sort: true, fixed: true}">问卷ID</th>
              <th lay-data="{field:'fromUserId', width:170}">所属用户id</th>
              <th lay-data="{field:'questionName', width:170}">问卷名</th>
              <th lay-data="{field:'remarks', width:180}">问卷备注</th>
              <th lay-data="{field:'button ', width:110}">编辑</th>
              <th lay-data="{field:'button ', width:190}">查看该问卷填写情况</th>

            </tr>
          </div>

          <div>
            {% for quest in quests %}
            <tr>

              <td lay-data="{type:'checkbox', fixed: 'left'}"></td>
              <td lay-data="{field:'id', width:110, sort: true, fixed: true}">{{quest.id}}</td>
              <td lay-data="{field:'fromUserId', width:170}">{{quest.fromUserId}}</td>
              <td lay-data="{field:'Name', width:170}">{{quest.Name}}</td>
              <td lay-data="{field:'remarks', width:180}">{{quest.remarks}}</td>
              <script type="text/html" id="barDemo">

                <button class="layui-btn layui-btn-xs"   name="compile" value="compile" onclick="Questionnaire('{{quest.id}}')">编辑</button>
              </script>

              <button class="layui-btn layui-btn-danger layui-btn-xs" name="fillingStatus" value="fillingStatus" onclick="nowShare('{{quest.id}}')">分享问卷{{quest.id}}</button>

              <script type="text/html" id="fillingStatus">
                <button class="layui-btn layui-btn-danger layui-btn-xs"   name="fillingStatus" value="fillingStatus" onclick="fillingStatus('{{quest.id}}')">查看</button>
              </script>
            </tr>

            {% endfor %}
          </div>

        </thead>
      </table>

    </div>
  </div>

  </div>
  <script src="js/jquery-3.6.0.min.js"></script>
  <script src="layui/layui-v2.6.8/layui/layui.js"></script>
  <script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
  <script src="js/bootstrap.min.js"></script>
  <script src="js/clipboard.min.js"></script>

  <script>
    //分享
    function nowShare(titleid) {
      var url;

      url = window.location.href; /* 获取完整URL */
      alert(url + "\n\n" + "id:" + titleid);
    }

  </script>
  <script>

    //跳转创建新问卷页面
    function newQuestionnaire() {

      window.location.href = "/newQuestionnaire"

    }
    //跳转
    function information() {

      window.location.href = '/information'

    }

    function Questionnaire(index) {
      alert(index);

      axios({
        url: '/questionnaireDone',
        method: 'post',
        data: {
          index
        }
      }).then(function (response) {
        let res = response.data;
        if (res.code === 200) {
          window.location.href = '/questionnaire'
        }
        else {
          console.log('失败');
        }
      }).catch({

      });

    }
    function logout() {
      axios({
        method: 'post',
        url: '/logout'
      }).then(function (response) {
        let res = response.data;
        if (res.code === 200) {
          window.location.href = '/login';
        }
      }).catch((err) => {

      });
    };
    function lookMeQ() {
      axios({
        method: 'post',
        url: '/myQuestionnaireDone'
      }).then(function (response) {
        let res = response.data;
        if (res.code == 200) {
          window.location.href = '/myQuestionnaire'
        }
        else {
          console.log('失败');
        }
      })

    }
    function share() {

    }
    function fillingStatus(index) {
      axios({
        url: '/fillingStatusDone',
        method: 'post',
        data: {
          index
        }
      }).then(function (response) {
        let res = response.data;
        if (res.code == 200) {
          window.location.href = '/fillingStatus'
        }
        else {
          console.log('失败');
        }
      })
    }
  </script>


</body>

</html>